package com.turing.post.selfwebservice.util;

import java.io.Serializable;
import java.math.BigInteger;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;

@SuppressWarnings("serial")
/**
 * 注册用户关联卡
 */
@Entity
@Table(name = "CARDHOLDERUSERLINK")
@IdClass(CardHolderUserLink.class)
public class CardHolderUserLink implements Serializable {
	/**
	 * 注册用户ID
	 */
	private BigInteger cardHolderUserId;
	/**
	 * 卡号
	 */
	private String cardNo;

	@Id
	@Column(name = "CARDHOLDERUSERID")
	public BigInteger getCardHolderUserId() {
		return cardHolderUserId;
	}

	public void setCardHolderUserId(BigInteger cardHolderUserId) {
		this.cardHolderUserId = cardHolderUserId;
	}

	@Id
	@Column(name = "CARDNO")
	public String getCardNo() {
		return cardNo;
	}

	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((getCardHolderUserId() == null) ? 0 : getCardHolderUserId().hashCode());
		result = prime * result + ((getCardNo() == null) ? 0 : getCardNo().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CardHolderUserLink other = (CardHolderUserLink) obj;
		if (getCardHolderUserId() == null) {
			if (other.getCardHolderUserId() != null)
				return false;
		} else if (!getCardHolderUserId().equals(other.getCardHolderUserId()))
			return false;
		if (getCardNo() == null) {
			if (other.getCardNo() != null)
				return false;
		} else if (!getCardNo().equals(other.getCardNo()))
			return false;
		return true;
	}
}